package com.heima.demo;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

public class Demo3 {
    public static void main(String[] args) throws Exception {
        //创建对象
        DatagramSocket ds = new DatagramSocket();
        //准备数据
        String s = "喷射战神" ;
        byte[] bytes = s.getBytes();
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length, InetAddress.getByName("255.255.255.255"),10001 );
        //发送数据
        ds.send(dp);
        ds.close();
    }
}
